-include rules.mk

PWDDIR = $(PWD)
BUIDIR = $(PWDDIR)/build
PACDIR = $(PWDDIR)/package
INCDIR = $(PWDDIR)/include
BINDIR = $(BUIDIR)/bin
OBJDIR = $(BUIDIR)/obj

export OBJDIR INCDIR PACDIR
OBJ =$(patsubst %.c, %.o, $(notdir $(wildcard $(PACDIR)/*.c)))
export OBJ


$(shell test -d $(BUIDIR) || mkdir $(BUIDIR))
$(shell test -d $(BINDIR) || mkdir $(BINDIR))
$(shell test -d $(OBJDIR) || mkdir $(OBJDIR))

OBJS = $(addprefix $(OBJDIR)/, $(OBJ)) $(OBJDIR)/main.o

$(OUTPUTNAME) : main.o
	make -C $(PACDIR)
	$(CC) $(OBJS) $(CFLAGS) -o $(BINDIR)/$(OUTPUTNAME)

main.o : main.c
	$(CC) -c main.c -I$(INCDIR) $(CFLAGS) -o $(OBJDIR)/main.o



.PHONY : clean clean_obj
clean :
	rm -r $(BUIDIR)

clean_obj :
	rm -r $(OBJDIR)

